package com.wanlian.candy.controller.session;

import com.wanlian.candy.controller.vo.MsgValitationVo;
import com.wanlian.entity.HistoryLogin;
import com.wanlian.vo.UserAuthorityVo;
import com.wanlian.entity.Authority;
import com.wanlian.entity.User;

import java.util.ArrayList;
import java.util.List;

public class UserSessionInfo {
    private User loginUser;
    private MsgValitationVo msgValitationVo;
    private List<UserAuthorityVo> userAuthorities;
    private List<Authority> authorities;
    private String sessionId;

    private List<HistoryLogin> historyLogins;

    private String realCode;

    public List<HistoryLogin> getHistoryLogins() {
        return historyLogins;
    }

    public void setHistoryLogins(List<HistoryLogin> historyLogins) {
        this.historyLogins = historyLogins;
    }

    public void addHistoryLogins(HistoryLogin historyLogin) {
        if (this.historyLogins == null) {
            this.historyLogins = new ArrayList<>();
        }
        this.historyLogins.add(historyLogin);
    }

    public User getLoginUser() {
        return loginUser;
    }

    public void setLoginUser(User loginUser) {
        this.loginUser = loginUser;
    }

    public MsgValitationVo getMsgValitationVo() {
        return msgValitationVo;
    }

    public void setMsgValitationVo(MsgValitationVo msgValitationVo) {
        this.msgValitationVo = msgValitationVo;
    }

    public List<UserAuthorityVo> getUserAuthorities() {
        return userAuthorities;
    }

    public void setUserAuthorities(List<UserAuthorityVo> userAuthorities) {
        this.userAuthorities = userAuthorities;
    }

    public List<Authority> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(List<Authority> authorities) {
        this.authorities = authorities;
    }

    public String getRealCode() {
        return realCode;
    }

    public void setRealCode(String realCode) {
        this.realCode = realCode;
    }

    public boolean checkCode(String code) {
        if (this.msgValitationVo == null) {
            return false;
        }
        boolean bResult = msgValitationVo.getCode().equals(code);
        return bResult;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
}
